@use '@scss/common' as *;
@use '../shared.scss';

.checkbox {
  position: relative;
  display: flex;
  align-items: center;
  padding: 1.75rem 2rem;

  &::before {
    content: '';
    width: calc(100% - 2px);
    position: absolute;
    height: 100%;
    left: 1px;
    top: 0;
    z-index: -1;
  }

  .button {
    all: unset;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;

    &:disabled {
      color: var(--theme-elevation-500);
    }

    &:focus,
    &:active {
      outline: none;
    }

    &:focus-visible {
      .input {
        @include outline;
      }
    }

    &:hover {
      :local() {
        .icon {
          opacity: 0.2;
        }
      }
    }
  }

  .errorLabel {
    margin: 0;
  }

  .htmlInput {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
  }

  .input {
    @include shared.formInput;
    & {
      padding: 0;
      line-height: 0;
      position: relative;
      width: 1rem;
      height: 1rem;
      min-width: 1rem;
      min-height: 1rem;
      margin-right: 0.5rem;
      margin-bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.3s ease;
    }
  }

  .icon {
    opacity: 0;
    transition: all 0.3s ease;
  }

  .label {
    cursor: pointer;
    margin: 0;
    color: var(--theme-text);
    margin-right: 0.75rem;
    transition: all 0.3s ease;
  }

  @include mid-break {
    padding: 1.75rem 1rem;
  }
}

.checked {
  :local() {
    .input {
      border-color: var(--color-base-0);

      .icon {
        opacity: 1 !important;
      }
    }

    .label {
      color: var(--color-base-0);
    }
  }
}
